Comments (4)
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.
@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.
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.
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)
- How to add text boxes and modify text colors?
- How to modify the color of text and add text boxes? HOT 1
- Insert column
- Set font color, no effect HOT 3
- Add NoFill to Existing Shape
- Cannot Change Font's isBold and LatinName in the Table Cell HOT 2
- AddPicture doesn't set height
- Lots of compiler warnings HOT 4
- SVG AddPicture: Incorrectly renders text in SVG HOT 2
- SVG AddPicture: Large-dimension SVG files lead to error opening in PowerPoint HOT 3
- Add Slide Note HOT 1
- Edit Slide Note
- Sub-pixel precision for shape position and size HOT 1
- SVG AddPicture: Non-square logos without width/height attributes are sized as squares
- "No Color" text highlight HOT 1
- Consider rasterizing SVGs at a higher resolution
- Setting shape outline color to `null` causes presentation validation to fail
- Get/Set corner radius of rounded rectangles HOT 1
- Add trim annotations
- Can't change font in table HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shapecrawler.