-
-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/font styles #94
Conversation
indent_style = tabs | ||
indent_style = tab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Visual Studio seems like do not recognize the tabs
value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few small suggestions. Nothing important.
src/D2DLibExport/D2DDevice.cs
Outdated
return handle == HANDLE.Zero ? null : new D2DStrokeStyle(this, handle, dashes, dashOffset, startCap, endCap); | ||
} | ||
|
||
public D2DPen CreatePen(D2DColor color, D2DDashStyle dashStyle = D2DDashStyle.Solid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a mix of spaces and tabs here.
[In] DWriteTextAlignment halign = DWriteTextAlignment.Leading, | ||
[In] DWriteParagraphAlignment valign = DWriteParagraphAlignment.Near); | ||
|
||
[DllImport(DLL_NAME, EntryPoint = "MeasureText", CharSet = CharSet.Unicode, | ||
CallingConvention = CallingConvention.Cdecl)] | ||
public static extern void MeasureText([In] HANDLE ctx, [In] string text, [In] string fontName, | ||
[In] FLOAT fontSize, ref D2DSize size); | ||
[In] FLOAT fontSize, ref D2DSize size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref
was removed from the above signature. Should it be removed here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ref
maybe is needed here becase it is a paramter to receive the function result. Maybe a return value is better, to be implemented in future.
public D2DDevice Device { get; private set; } | ||
|
||
public float[] Dashes { get; private set; } | ||
|
||
public float DashOffset { get; private set; } | ||
|
||
public D2DCapStyle StartCap { get; private set; } = D2DCapStyle.Flat; | ||
|
||
public D2DCapStyle EndCap { get; private set; } = D2DCapStyle.Flat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These properties can be get-only.
public D2DDevice Device { get; private set; } | |
public float[] Dashes { get; private set; } | |
public float DashOffset { get; private set; } | |
public D2DCapStyle StartCap { get; private set; } = D2DCapStyle.Flat; | |
public D2DCapStyle EndCap { get; private set; } = D2DCapStyle.Flat; | |
public D2DDevice Device { get; } | |
public float[] Dashes { get; } | |
public float DashOffset { get; } | |
public D2DCapStyle StartCap { get; } = D2DCapStyle.Flat; | |
public D2DCapStyle EndCap { get; } = D2DCapStyle.Flat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tried readonly keyword but looks like I can't use it because C# version is 7.3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only need to remove the private set;
bit, not add anything else. That doesn't require any recent C# version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Sorry I am not noticed you have provided a suggestion change, thanks! d9929fe
src/Examples/Examples.csproj
Outdated
<ItemGroup> | ||
<Compile Update="SampleCode\TextStyles.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Update="SampleCode\ClipMaskDraw.cs" /> | ||
<Compile Update="SampleCode\LineCapStyle.cs" /> | ||
</ItemGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this whole <ItemGroup>
can be removed.
src/d2dlib/Text.cpp
Outdated
LPCWSTR fontName, FLOAT fontSize, D2D1_RECT_F* rect, | ||
LPCWSTR fontName, FLOAT fontSize, D2D1_RECT_F rect, | ||
DWRITE_FONT_WEIGHT fontWeight, DWRITE_FONT_STYLE fontStyle, | ||
DWRITE_FONT_STRETCH fontStretch, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mix of tabs and spaces here.
@drewnoakes Thanks very much! |
Backport of patches in: jingwood/d2dlib#94 jingwood/d2dlib@d9929fe
This pull request adds the font weight, font style and font stretch flags to
DrawText
function.Sample Program
