Skip to content

Commit 51c254b

Browse files
committed
Make font property mandatory in Text
1 parent 4ee9621 commit 51c254b

File tree

4 files changed

+5
-24
lines changed

4 files changed

+5
-24
lines changed

docs/docs/text/text.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Please note that the y origin of the Text is the bottom of the text, not the top
1111
| Name | Type | Description |
1212
|:------------|:-----------|:----------------------------------------------------------------|
1313
| text | `string` | Text to draw |
14-
| font | `SkFont` | Font to use (optional) |
14+
| font | `SkFont` | Font to use |
1515
| x | `number` | Left position of the text (default is 0) |
1616
| y | `number` | Bottom position the text (default is 0, the ) |
1717

@@ -30,7 +30,6 @@ export const HelloWorld = () => {
3030
x={0}
3131
y={fontSize}
3232
text="Hello World"
33-
// Font is optional
3433
font={font}
3534
/>
3635
</Canvas>

package/cpp/rnskia/dom/props/FontProp.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,12 @@ class FontProp : public DerivedProp<SkFont> {
3131
"Expected SkFont object or null/undefined for the Font property.");
3232
}
3333
} else {
34-
auto fm = SkFontMgr::RefDefault();
35-
sk_sp<SkTypeface> typeface =
36-
fm->legacyMakeTypeface(nullptr, SkFontStyle());
37-
auto font = std::make_shared<SkFont>(SkFont(typeface));
38-
font->setSize(14);
39-
setDerivedValue(font);
34+
setDerivedValue(nullptr);
4035
}
4136
}
4237

4338
private:
4439
NodeProp *_fontProp;
4540
};
4641

47-
} // namespace RNSkia
42+
} // namespace RNSkia

package/src/dom/nodes/drawings/Text.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,8 @@ export class TextNode extends JsiDrawingNode<TextProps, SkFont | null> {
2323

2424
protected deriveProps() {
2525
const { font } = this.props;
26-
if (font === null) {
27-
return null;
28-
} else if (font === undefined) {
29-
console.warn(
30-
"<Text />: the font property is mandatory on React Native Web"
31-
);
26+
if (!font) {
3227
return null;
33-
// return this.Skia.Font(
34-
// this.Skia.FontMgr.System().matchFamilyStyle("System", {
35-
// width: 5,
36-
// weight: 400,
37-
// slant: 0,
38-
// }),
39-
// 14
40-
// );
4128
}
4229
return font;
4330
}

package/src/dom/types/Drawings.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export interface DiffRectProps extends DrawingNodeProps {
109109
}
110110

111111
export interface TextProps extends DrawingNodeProps {
112-
font?: SkFont | null;
112+
font: SkFont | null;
113113
text: string;
114114
x: number;
115115
y: number;

0 commit comments

Comments
 (0)