Jump to content

Displaying a TUniFont as a barcode.


peeryog

Recommended Posts

I need to display a TUniDBText as a barcode.  I have a Code 128 ttf font installed on the server.  At design time the font displays correctly but in local debug mode it reverts to the default font, probably Tahoma. This in on the same desktop where development is occurring.  What am I doing wrong?

 

Thanks

 

Peter

Link to comment
Share on other sites

7 hours ago, peeryog said:

I need to display a TUniDBText as a barcode.  I have a Code 128 ttf font installed on the server.  At design time the font displays correctly but in local debug mode it reverts to the default font, probably Tahoma. This in on the same desktop where development is occurring.  What am I doing wrong?

 

Thanks

 

Peter

Hello, https://stackoverflow.com/questions/24990554/how-to-include-a-font-ttf-using-css

https://www.pagecloud.com/blog/how-to-add-custom-fonts-to-any-website

try to add this in Your css (customcss)

@font-face{
  font-family: "Font Name";
  src: url("../fonts/font-name.ttf") format("truetype");
}

font files must be included in root: rootdit/fonts/

Link to comment
Share on other sites

Thank you both very much for the response.

The test case is pretty simple.  I drop a TUniLabel on the project, insert '12345678' in the caption field and select font "Code 128" from the drop down list. The label displays as a barcode in the IDE . However when I run it , the font changes to an alternate font.

Inspecting the element within the browser displays "font-family : Code 128; " with a warning and the message "invalid property"

I am showing my inexperience here.

 

I modified the addition to reflect the correct font as below

@font-face{
       font-family: "Code 128";
       src: url("../fonts/code128.ttf") format("truetype");
}

When you say add to css(customcss) I am assuming you mean the CustomCSS property in the ServerModule? Within the style tags?

You say font files must be included in the root. Since this is running in Server mode I think you mean in the projects exe root, for example  c:\my barcode project files\Win32\Debug\ would be my root in this case? I have created a 'fonts' folder in this root folder and added the Code128.tff files.

 

I have done as you suggested using the information you provided, but I am still not seeing the barcode and am getting the same invalid property warning.

 

Does the TUnilabel need to be linked to the CustomCSS using LayoutConfig>CSS property or should it automatically find it based on the common font name?

 

Thanks

Peter

 

Link to comment
Share on other sites

1 hour ago, peeryog said:

Thank you both very much for the response.

The test case is pretty simple.  I drop a TUniLabel on the project, insert '12345678' in the caption field and select font "Code 128" from the drop down list. The label displays as a barcode in the IDE . However when I run it , the font changes to an alternate font.

Inspecting the element within the browser displays "font-family : Code 128; " with a warning and the message "invalid property"

I am showing my inexperience here.

 

I modified the addition to reflect the correct font as below

@font-face{
       font-family: "Code 128";
       src: url("../fonts/code128.ttf") format("truetype");
}

When you say add to css(customcss) I am assuming you mean the CustomCSS property in the ServerModule? Within the style tags?

You say font files must be included in the root. Since this is running in Server mode I think you mean in the projects exe root, for example  c:\my barcode project files\Win32\Debug\ would be my root in this case? I have created a 'fonts' folder in this root folder and added the Code128.tff files.

 

I have done as you suggested using the information you provided, but I am still not seeing the barcode and am getting the same invalid property warning.

 

Does the TUnilabel need to be linked to the CustomCSS using LayoutConfig>CSS property or should it automatically find it based on the common font name?

 

Thanks

Peter

 

Hello, can you try to add this in your css file (not in custom css)

@font-face{
       font-family: "Code 128";
       src: url("../fonts/code128.ttf") format("true/type");
}

Link to comment
Share on other sites

Use this in your servermodule/customcss:

@font-face {
  font-family: 'Code128';   
  src: url('files/fonts/Code128.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}


Put the attached Code128.ttf file in the "fonts" folder which you create under "files", which is under the app dir.

Install and use the newly added font version for your unilabel, notice that the font name is now without a space.
I had to remove the space from the font name definition in the ttf file to make this work.

Also added some other versions of the font if needed. Using them all it would be:

@font-face {
  font-family: 'Code128';   
  src: url('files/fonts/Code128.ttf') format('truetype'),
   url('files/fonts/Code128.eot') format('embedded-opentype'),
   url('files/fonts/Code128.woff2') format('woff2'),
   url('files/fonts/Code128.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

barcode.jpg

Code128.ttf

Code128.woff2 Code128.eot Code128.svg

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...