Skip to content
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

Merged
merged 6 commits into from
Oct 30, 2022
Merged

Feature/font styles #94

merged 6 commits into from
Oct 30, 2022

Conversation

jingwood
Copy link
Owner

@jingwood jingwood commented Oct 28, 2022

This pull request adds the font weight, font style and font stretch flags to DrawText function.

Sample Program
image

@jingwood jingwood requested a review from drewnoakes October 28, 2022 13:56
indent_style = tabs
indent_style = tab
Copy link
Owner Author

@jingwood jingwood Oct 28, 2022

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.

Copy link
Collaborator

@drewnoakes drewnoakes left a 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.

return handle == HANDLE.Zero ? null : new D2DStrokeStyle(this, handle, dashes, dashOffset, startCap, endCap);
}

public D2DPen CreatePen(D2DColor color, D2DDashStyle dashStyle = D2DDashStyle.Solid,
Copy link
Collaborator

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,
Copy link
Collaborator

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?

Copy link
Owner Author

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.

Comment on lines +42 to +50
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;
Copy link
Collaborator

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.

Suggested change
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;

Copy link
Owner Author

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.

Copy link
Collaborator

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.

Copy link
Owner Author

@jingwood jingwood Oct 30, 2022

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

Comment on lines 16 to 22
<ItemGroup>
<Compile Update="SampleCode\TextStyles.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="SampleCode\ClipMaskDraw.cs" />
<Compile Update="SampleCode\LineCapStyle.cs" />
</ItemGroup>
Copy link
Collaborator

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.

Comment on lines 29 to 31
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,
Copy link
Collaborator

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.

@jingwood
Copy link
Owner Author

@drewnoakes Thanks very much!

@jingwood jingwood merged commit 1f1c0d0 into master Oct 30, 2022
@jingwood jingwood deleted the feature/fontStyles branch October 30, 2022 05:12
@jingwood jingwood mentioned this pull request Oct 30, 2022
jingwood added a commit that referenced this pull request Oct 30, 2022
nikeee added a commit to nikeee/nud2dlib that referenced this pull request Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants