Giter Site home page Giter Site logo

Comments (4)

jcoliz avatar jcoliz commented on June 11, 2024

Yeah, this is troublesome. It also changes the font family name as well for me. The workaround I have found is to not change the textframe text, but rather change only the paragraph text. Then I just make sure there are as many paragraphs already in the source presentation that I'll need.

from shapecrawler.

jcoliz avatar jcoliz commented on June 11, 2024

@ashahabov Are you interested in a PR with a failing test for this? https://github.com/jcoliz/ShapeCrawler/tree/issue/638-text-font-size

        [Test]
        [Explicit]
        [SlideShape("001.pptx", 1, "TextBox 3")]
        [SlideShape("001.pptx", 3, "Text Placeholder 3")]
        public void Text_Setter_doesnt_change_font_size(IShape shape)
        {
            // Arrange
            var expected = shape.TextFrame.Paragraphs[0].Portions[0].Font.Size;

            // Act
            shape.TextFrame.Text = "New text";

            // Assert
            shape.TextFrame.Paragraphs[0].Portions[0].Font.Size.Should().Be(expected,$"{shape.Name} text size has changed");
        }

What's interesting is that this test only fails for the "Text Placeholder 3" case. "Textbox 3" case passes.

from shapecrawler.

jcoliz avatar jcoliz commented on June 11, 2024

There is some suspicious stuff going on in FontService.GetAdjustedFontSize.

At the top of the method:

        paint.TextSize = fontSize;

And then at the bottom:

        const int dpi = 96;
        var points = Math.Round(paint.TextSize * 72 / dpi, 0);
        return (int)points;

Ergo, text size is guaranteed to get a 25% cut, even if the wordWidth never hits the rect.Right.

from shapecrawler.

jcoliz avatar jcoliz commented on June 11, 2024

I now think the problem is that FontService.GetAdjustedFontSize sets the SKPaint.TextSize (in pixels) directly to the font size )in points), without making a points-to-pixels conversion. Once the previous PR gets through, I'll submit this for review.

from shapecrawler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.