Click here to Skip to main content
14,239,876 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am using TTF file through Embedded Resources but not showing font in RTBox but
same if i am applying on label1 on set property
Label1.UseCompatibleTextRendering = true font will be show if Property false font not show same thing i want to use in RTBox it can be possible.

What I have tried:

<system.drawing.toolboxbitmap(gettype(myttf), "myttf.ttf")="">
Public Class MyTTF
Inherits Windows.Forms.RichTextBox
End Class
Posted
Updated 12-Jul-19 7:11am
v2
Comments
Maciej Los 12-Jul-19 7:10am
   
What is RTBox?
Computechsoft 12-Jul-19 7:13am
   
RichTextBox
Rate this:
Please Sign up or sign in to vote.

Solution 1

   
Rate this:
Please Sign up or sign in to vote.

Solution 2

   
Comments
Computechsoft 12-Jul-19 7:50am
   
RTBox.SelectionFont = RTBox.GetSymbology39(14, FontStyle.Regular)

GetSymbology39 is ReadOnly Property another this is This font is not install in
Windows font folder i am using this property Through Embedded Resources.
but font is not display in RTBox. If i installed in windows font folder so (GetSymbology39) property work fine. without installation not work.
MadMyche 12-Jul-19 11:22am
   
I would recommend including the back history, it is pertinent to know that you are not using an installed font and that you have asked questions previously about this same font deployed
Rate this:
Please Sign up or sign in to vote.

Solution 3

See the last answer in the discussion here: Install Fonts In Windows If It Is Missing - VB.NET | Dream.In.Code[^]
   
Comments
Computechsoft 12-Jul-19 14:05pm
   
I see the last answer but i don't want to install font in windows font folder. I want to use font from Application resources folder. Its mean "Embedded Resources". I have applied this kindly check this i hope you will solve this issue.
************************************************************************

Imports System.Drawing.Text
Imports System.Runtime.InteropServices

Public Class Form1
Public Property SelectionFont As System.Drawing.Font
Public _PrivateFontColection As PrivateFontCollection = Nothing

ReadOnly Property GetSymbology(ByVal Size As Single, ByVal style As FontStyle) As Font
Get
If _PrivateFontColection Is Nothing Then LoadFont()
Return New Font(_PrivateFontColection.Families(0), Size, style)
End Get
End Property

Public Property StartingIndex As Integer

Private Sub LoadFont()
_PrivateFontColection = New PrivateFontCollection
Dim fontMemPointer As IntPtr = Marshal.AllocCoTaskMem(My.Resources.TTF.Length)
Marshal.Copy(My.Resources.TTF, StartingIndex, fontMemPointer, My.Resources.TTF.Length)
_PrivateFontColection.AddMemoryFont(fontMemPointer, My.Resources.TTF.Length)
Marshal.FreeCoTaskMem(fontMemPointer)
End Sub

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RichTextBox1.SelectionFont = RichTextBox1.GetSymbology(14, FontStyle.Regular)
End Sub
End Class

Best regards
RickZeeland 12-Jul-19 15:58pm
   
It should be like this:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
RichTextBox1.SelectionFont = GetSymbology(14, FontStyle.Regular)
End Sub

If it does not work, try something like this:
RichTextBox1.SelectionFont = New Font("Tahoma", 12, FontStyle.Bold)
Computechsoft 5 days ago
   
RichTextBox1.SelectionFont = RichTextBox1.GetSymbology(14, FontStyle.Regular)
if font install in windows font folder this is work if not install no work.
i don't want to install font in windows font folder. I am Using "Embedded Resources"

***********************************************************************

RichTextBox1.SelectionFont = New Font("Tahoma", 12, FontStyle.Bold)
Same Situation here

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100