Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions native/include/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ enum TextBaseline {
};

enum TextDirection {
kInherit,
kLTR,
kRTL
};
Expand Down
8 changes: 4 additions & 4 deletions native/src/context2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ sk_context_state* create_default_state() {
state->imageSmoothingQuality = kLow;
state->textAlign = kStart;
state->textBaseline = kAlphabetic;
state->direction = kLTR;
state->direction = kInherit;
state->font = new Font();
state->font->size = 10;
state->font->family = strdup("sans-serif");
Expand Down Expand Up @@ -298,7 +298,7 @@ extern "C" {
skia::textlayout::ParagraphStyle paraStyle;
paraStyle.setTextAlign(skia::textlayout::TextAlign::kLeft);
paraStyle.setTextStyle(tstyle);
paraStyle.setTextDirection(skia::textlayout::TextDirection(context->state->direction));
paraStyle.setTextDirection(skia::textlayout::TextDirection(context->state->direction == kRTL ? 0 : 1));

auto builder = skia::textlayout::ParagraphBuilderImpl::make(paraStyle, fontCollection, SkUnicode::Make());
builder->addText(text, textLen);
Expand Down Expand Up @@ -395,10 +395,10 @@ extern "C" {
paintX = x - lineWidth;
break;
case TextAlign::kStart:
paintX = context->state->direction == TextDirection::kLTR ? x : x - lineWidth;
paintX = context->state->direction == TextDirection::kRTL ? x - lineWidth : x;
break;
case TextAlign::kEnd:
paintX = context->state->direction == TextDirection::kLTR ? x - lineWidth : x;
paintX = context->state->direction == TextDirection::kRTL ? x : x - lineWidth;
break;
}
auto needScale = lineWidth > maxWidth;
Expand Down
5 changes: 3 additions & 2 deletions src/context2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ enum CTextAlign {
}

enum CTextDirection {
ltr = 0,
rtl = 1,
inherit = 0,
ltr = 1,
rtl = 2,
}

enum CTextBaseline {
Expand Down