How to .SHX fonts
Moderators: SDS, support, admin
How to .SHX fonts
Hi,
Entity->Style = CadMngr->CurrDimStyle;
Entity->Style->TextStyle->FontName = "SIMPLEX";
Entity->Style->TextStyle->PrimaryFont = "C:\\BILSAR\\SIMPLEX.SHX";
The code snippet above is trying to use SIMPLEX text style with no success.
BILSAR directory contains the simplex. shx file.
When I examine with the debugger PrimayFont is exactly like the above.
What am I missing or could you provide an example on how to use simplex.shx fonts.
Thanks
aby
Entity->Style = CadMngr->CurrDimStyle;
Entity->Style->TextStyle->FontName = "SIMPLEX";
Entity->Style->TextStyle->PrimaryFont = "C:\\BILSAR\\SIMPLEX.SHX";
The code snippet above is trying to use SIMPLEX text style with no success.
BILSAR directory contains the simplex. shx file.
When I examine with the debugger PrimayFont is exactly like the above.
What am I missing or could you provide an example on how to use simplex.shx fonts.
Thanks
aby
Re: How to .SHX fonts
Hello aby.
The code you posted changes the text style for a dimension object. However it's not enough to affect visualization. All entities that use the modified style must be loaded to converter. For example try to change dimension text visualization with the simply AutoCAD file (attached). It contains one dimension entity only. Loading the dimension from entities section and MText from dimension's block required to change dimension text visualization: Please note, dimension inner entities contained in blocks section.
Of course SHX fonts must be switched on in your application.
Alexander.
The code you posted changes the text style for a dimension object. However it's not enough to affect visualization. All entities that use the modified style must be loaded to converter. For example try to change dimension text visualization with the simply AutoCAD file (attached). It contains one dimension entity only. Loading the dimension from entities section and MText from dimension's block required to change dimension text visualization:
Code: Select all
TsgDXFDimension* dim = (TsgDXFDimension*)FImg->Converter->Entities[0];
FImg->Converter->Loads(dim);
TsgDXFGroup* group = (TsgDXFGroup*)FImg->Converter->Sections[csEntities];
FImg->Converter->Loads(((TsgDXFBlock*)group->Entities[3])->Entities[6]);
//if not doublebuffered. Otherwise FImg->GetExtents();
sgPaintBox->Invalidate();
Of course SHX fonts must be switched on in your application.
Alexander.
- Attachments
-
- dimension.zip
- (7.78 KiB) Downloaded 2749 times
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to .SHX fonts
Alexander.
I've downloaded your dwg and try to do your posting . I need some clarifications.
TsgDXFDimension* dim = (TsgDXFDimension*)FImg->Converter->Entities[0];
FImg->Converter->Loads(dim);
1) From above I understand Entites[0] is aTsgDXFDimension object. ( True or false)
TsgDXFGroup* group = (TsgDXFGroup*)FImg->Converter->Sections[csEntities];
FImg->Converter->Loads(((TsgDXFBlock*)group->Entities[3])->Entities[6]);
2) What is group csEntities ? What is Group and Why Entities[3] && Entities[6];
What are they referring?
Please could you post a working example on how to change to a simplex fonts. It can be on Delphi it doesnt matter.
I've downloaded your dwg and try to do your posting . I need some clarifications.
TsgDXFDimension* dim = (TsgDXFDimension*)FImg->Converter->Entities[0];
FImg->Converter->Loads(dim);
1) From above I understand Entites[0] is aTsgDXFDimension object. ( True or false)
TsgDXFGroup* group = (TsgDXFGroup*)FImg->Converter->Sections[csEntities];
FImg->Converter->Loads(((TsgDXFBlock*)group->Entities[3])->Entities[6]);
2) What is group csEntities ? What is Group and Why Entities[3] && Entities[6];
What are they referring?
Please could you post a working example on how to change to a simplex fonts. It can be on Delphi it doesnt matter.
Re: How to .SHX fonts
Hello aby.
You're correct, Entites[0] is a TsgDXFDimension object. The attached file contains one entity (dimension) only, so there is only one entity in Converter->Entities list. However DWG/DXF structure provides a dimension consists of a set of other entities such as lines, solids, MText. These entities can be accessed via BLOCKS section FImg->Converter->Sections[csBlocks]. My previous post contains an error, sorry. Group must be refer to BLOCKS, not ENTITIES:Dimension's block have index 3 and the MText have index 6 within block's entities.
MText can be also accessed as TsgDXFDimension->Block->Entities:
Any of above posted snippets must be run after your code changing the text style. More complex files with multiple dimensions/texts require reload all entities that use the modified style.
Alexander.
You're correct, Entites[0] is a TsgDXFDimension object. The attached file contains one entity (dimension) only, so there is only one entity in Converter->Entities list. However DWG/DXF structure provides a dimension consists of a set of other entities such as lines, solids, MText. These entities can be accessed via BLOCKS section FImg->Converter->Sections[csBlocks]. My previous post contains an error, sorry. Group must be refer to BLOCKS, not ENTITIES:
Code: Select all
TsgDXFDimension* dim = (TsgDXFDimension*)FImg->Converter->Entities[0];
FImg->Converter->Loads(dim);
// FImg->Converter->Sections[csEntities] ---- incorrect
TsgDXFGroup* group = (TsgDXFGroup*)FImg->Converter->Sections[csBlocks];
FImg->Converter->Loads(((TsgDXFBlock*)group->Entities[3])->Entities[6]);
//if not doublebuffered. Otherwise FImg->GetExtents();
sgPaintBox->Invalidate();
MText can be also accessed as TsgDXFDimension->Block->Entities:
Code: Select all
TsgDXFDimension* dim = (TsgDXFDimension*)FImg->Converter->Entities[0];
FImg->Converter->Loads(dim);
FImg->Converter->Loads(dim->Block->Entities[6]);
//if not doublebuffered. Otherwise FImg->GetExtents();
sgPaintBox->Invalidate();
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to .SHX fonts
Alexander,
Thanks for your clarifying post.
First I'm not using MText. Simply I'm using Text.
FImg->Converter->Loads(((TsgDXFBlock*)group->Entities[3])->Entities[6]);
So we don't need this line. It is giving an error if it is included.
The bad news is the issue is party been solved. It is continuing to display the default in Arial fonts.
The good news is If saved to a file and opened on AutoCad it is displaying as required.
Good luck,
Aby
Thanks for your clarifying post.
First I'm not using MText. Simply I'm using Text.
FImg->Converter->Loads(((TsgDXFBlock*)group->Entities[3])->Entities[6]);
So we don't need this line. It is giving an error if it is included.
The bad news is the issue is party been solved. It is continuing to display the default in Arial fonts.
The good news is If saved to a file and opened on AutoCad it is displaying as required.
Good luck,
Aby
Re: How to .SHX fonts
Hello aby.
The code was provided for the attached file. This file visualization must be changed correctly. Please specify that have you meant by "issue is partially been solved". Have you received the visualization with SHX fonts for the attached file?
For any other drawing all entities using the modified style must be reloaded. Save/load file will reload all parameters. However it can be useful if only export library owned.
Alexander.
The code was provided for the attached file. This file visualization must be changed correctly. Please specify that have you meant by "issue is partially been solved". Have you received the visualization with SHX fonts for the attached file?
For any other drawing all entities using the modified style must be reloaded. Save/load file will reload all parameters. However it can be useful if only export library owned.
Alexander.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to .SHX fonts
Hello aby.
The following code can be used to change text style for an entity then reload all affected entities: I attach the file to test the snippet.
Alexander.
The following code can be used to change text style for an entity then reload all affected entities:
Code: Select all
var
dim: TsgDXFDimension;
block: TsgDXFBlock;
I: integer;
begin
dim := TsgDXFDimension(Img.Converter.entities[some_index]);
dim.Style.TextStyle.FontName := 'SIMPLEX';
dim.Style.TextStyle.PrimaryFont := 'SIMPLEX.SHX';
for I := 0 to Img.Converter.Sections[csBlocks].Count - 1 do
begin
block := TsgDXFBlock(Img.Converter.Sections[csBlocks].Entities[I]);
ChangeStyle(block)
end;
ChangeStyle(Img.Converter.Sections[csEntities]);
Img.GetExtents();
end;
procedure TForm1.ChangeStyle(group: TsgDXFGroup);
var
I: integer;
ent: TsgDXFEntity;
begin
for I := 0 to group.Count - 1 do
begin
ent := TsgDXFEntity(group.Entities[I]);
if (ent.EntType = ceDimension) or (ent.EntType = ceMText) or (ent.EntType = ceText) or (ent.EntType = ceAttrib) or (ent.EntType = ceAttdef) then
Img.Converter.Loads(ent);
if (ent.EntType = ceInsert) then
ChangeStyle(TsgDXFGroup(ent));
end;
end;
Alexander.
- Attachments
-
- styles.zip
- (12.63 KiB) Downloaded 3921 times
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support