Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Textblock: Font type

Dominic Wyss
Booster
Hi all,

I'm trying to create a multipurpose textblock function. Basically its working but I have trouble with setting correct font style and font face.
Any ideas why? AC finds no errors.
!-- Init

	_iPgNr = 0
	_iBkNr = 0
	p_to_m = GLOB_SCALE / 1000


!-- Syles

	define style{2} "globStyle" "Papyrus",       2.5 * p_to_m, 4
	define style{2} "S1"        "Arial",         1.0 * p_to_m, 0
	define style{2} "S2"        "Times",         1.5 * p_to_m, 1
	define style{2} "S3"        "Luminari",      4.0 * p_to_m, 0
	define style{2} "S4"        "Arial Black",   4.0 * p_to_m, 32


!-- Base

	hotspot2 0,0


!-- Setup _rt

	dict _rt

	_rt.x = 0.5
	_rt.y = 0.5
	_rt.anchor = 1
	_rt.align = 1
	_rt.style = "globStyle"


!-- First Block

	_rt.line[1].part[1].s = "S3"
	_rt.line[1].part[1].v = "Luminari normal "
	_rt.line[1].part[2].s = "S4"
	_rt.line[1].part[2].v = "Arial Black sup "
	_rt.line[1].part[3].s = "S3"
	_rt.line[1].part[3].v = "Luminari normal "
	_rt.line[1].part[4].s = "S4"
	_rt.line[1].part[4].v = "Arial Black sup"

	_rt.line[2].v = "Times bold"
	_rt.line[2].s = "S2"

	_rt.line[3].v = "Papyrus underline"
	!_rt.line[3].s = "S3" !-> use global style

	_rt.line[4].s = "S1"
	_rt.line[4].v = "Arial normal"

	_rt.line[5].part[1].s = "S1"
	_rt.line[5].part[1].v = ""
	_rt.line[5].part[2].s = "S2"
	_rt.line[5].part[2].v = "Times Bold"

	gosub "rtBlock"

	rect2 _rt.x, _rt.y, _rt.x + _rtWidth, _rt.y + (-1 * _rtHeight)


!-- Second Block

	add2 0,-1* (_rtHeight + 0.1)

	_rt.line[1].s = "S1"
	_rt.line[1].v = "Luminari normal"

	gosub "rtBlock"

	rect2 _rt.x, _rt.y, _rt.x + _rtWidth, _rt.y + (-1 * _rtHeight)



!=======================================================================================================================
end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end !
!=======================================================================================================================




!=======================================================================================================================
"rtBlock":
! ----------------------------------------------------------------------------------------------------------------------
! Mehrzeiliger Text als Richtext ausgeben.
! Es können mit .part[] pro Paragraph mehrere verschiedene Textstile gesetzt werden.
! Stift muss vor Aufruf gesetzt werden.
!-----------------------------------------------------------------------------------------------------------------------
!
! Caller:
! _rt              - (dict)
!    .x            - (real)   x-Position des Richtextes
!    .y            - (real)   y-Position des Richtextes
!    .anchor       - (int)    Textanker
!    .align        - (int)    Ausrichtung der Paragraphen
!    .style        - (string) Style für alle einfachen Zeilen
!    .line      - (array)  Array mit Texten pro Zeile
!
!-----------------------------------------------------------------------------------------------------------------------
!
! Responder:
! _rtHeight        - (real)   Textblock Höhe
! _rtWidth         - (real)   Textblock Breite
!
!-----------------------------------------------------------------------------------------------------------------------
!
! Other:
! _iPgNr           - (int)   Paragraph-Index (am Anfang des Scipts initialisieren und auf 0 setzen)
! _iBkNr           - (int)   Block-Index (am Anfang des Scipts initialisieren und auf 0 setzen)
!
!-----------------------------------------------------------------------------------------------------------------------
!
! Help:
! mögliche Struktur für _rt.line[]:
!    .line.s         - (string) Style (optional)
!    .line.v         - (string) Text
!
! oder:
!    .line.part.s - (string) Style
!    .line.part.v - (string) Text
!
!    * m darf aktuell maximal 4 sein! (weitere Teile werden ignoriert)
!
!=======================================================================================================================

	__nLines = vardim1(_rt.line)

	for q = 1 to __nLines
		_iPgNr = _iPgNr+1
		put _iPgNr

		if haskey(_rt.line.v) then
			if haskey(_rt.line.s) then

				paragraph _iPgNr _rt.align, 0, 0, 0, 1
					style _rt.line.s
					_rt.line.v + "\ts = " + _rt.line.s
				endparagraph

			else

				paragraph _iPgNr _rt.align, 0, 0, 0, 1
					_rt.line.v + "\tgs = " + _rt.style
				endparagraph

			endif

		else
			if haskey(_rt.line.part) then
				if vardim1(_rt.line.part) = 1 then

					paragraph _iPgNr _rt.align, 0, 0, 0, 1
						style _rt.line.part[1].s : _rt.line.part[1].v
					endparagraph

				endif

				if vardim1(_rt.line.part) = 2 then

					paragraph _iPgNr _rt.align, 0, 0, 0, 1
						style _rt.line.part[1].s : _rt.line.part[1].v
						style _rt.line.part[2].s : _rt.line.part[2].v
					endparagraph

				endif

				if vardim1(_rt.line.part) = 3 then

					paragraph _iPgNr _rt.align, 0, 0, 0, 1
						style _rt.line.part[1].s : _rt.line.part[1].v
						style _rt.line.part[2].s : _rt.line.part[2].v
						style _rt.line.part[3].s : _rt.line.part[3].v
					endparagraph

				endif

				if vardim1(_rt.line.part) >= 4 then

					paragraph _iPgNr _rt.align, 0, 0, 0, 1
						style _rt.line.part[1].s : _rt.line.part[1].v
						style _rt.line.part[2].s : _rt.line.part[2].v
						style _rt.line.part[3].s : _rt.line.part[3].v
						style _rt.line.part[4].s : _rt.line.part[4].v
					endparagraph

				endif

			else

				paragraph _iPgNr _rt.align, 0, 0, 0, 1
				!style _rt.style
				"No Text to print!"
				endparagraph

			endif

		endif

	next q

	_iBkNr = _iBkNr+1
	__bkName = "bk" + str("%",_iPgNr)

	style _rt.style
	textblock_ __bkName 0, _rt.anchor, 0, 1, 1, 0, __nLines,
		get(__nLines)

	richtext2 _rt.x, _rt.y, __bkName

	_dummy = REQUEST ("TEXTBLOCK_INFO", __bkName, _rtWidth, _rtHeight)
	_dummy = removekey(_rt.line)

return

Thanks for any help

Dominic
AC23 CHE - macOS Catalina
2 REPLIES 2

Dominic Wyss
Booster
I did some testig and I think it's a general problem with paragraphs and different fonts.
I created a native text in ac with several lines and different fonts each line.
then saved as new object.
source code is as expected but representation is wrong.

paragraph
set style "style 1"
"text"
endparagraph

paragraph
set style "style 2"
"text"
endparagraph





What am I doing wrong?
Dominic
AC23 CHE - macOS Catalina

Peter Baksa
Graphisoft
Graphisoft

The problem is with font names, all used style's font names have to be correct.

In GDL the font names visible on the Archicad UI can't be used. REQUEST "FONTNAMES_LIST" returns a list of installed fonts.  "Arial" can be "Arial Western" or "Arial Central European", etc...

 

Péter Baksa
Software Engineer, Library as a Platform
GRAPHISOFT SE, Budapest

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!