Run AHK V2 as ANSI and 32-bit

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

08 Nov 2023, 15:15

Finally, I was able to get at least some result. Although I still don't understand anything about hieroglyphs and their crazy encodings :lol:
character_map_demo_with_pdf.zip
character_map.ahk + character_map.pdf
(26.63 KiB) Downloaded 37 times
Slightly modified ChrA function, renamed into Chr3, for 2-byte encoded symbols. Symbol's output of GBK-EUC-H encoder is equal to Windows : Simplified Chinese charset in Windows Character Map program.
The MS Gothic font was chosen because several other fonts simply refused to load, causing failure HPDF_INVALID_FONT_NAME.

Latest LIBHPDF.ahk library (some constants was added, also cosmetic and QoL changes)
LIBHPDF.zip
Latest LIBHPDF.ahk
(6.13 KiB) Downloaded 40 times
Please post your script code inside [code] ... [/code] block. Thank you.
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

09 Nov 2023, 20:29

A couple of news.

Converting slide_show_demo.c was failed. It's constantly thrown exception with 0xC0000005 code on the first HPDF_Page_CreateDestination(page) function call.
error_handler is silent «as killed» in this situation.
I don't know what's going on and how it's possible to diagnose this annoying situation.

Just for research purposes the link to the «problem» is below:
slide_show_demo.zip
(1.76 KiB) Downloaded 38 times

Now to other news.

LIBHPDF.ahk was updated. Version raised to 1.3.
  • All static constants of all functions that had them are now available globally.
  • Added missing extended graphics processing functions.
  • Fixed several bugs found in DllCall parameters.
  • hpdf_errors.ahk now deprecated. error_handler with error codes moved to LIBHPDF.ahk.
    Just comment or remove #include "Lib\hpdf_errors.ahk" to avoid unexpected exceptions.
  • Immediate ExitApp(1) after closing MsgBox with a warning added to error_handler function.
  • The printf() function has been added to help with debugging. Usage is the same as in C, with formatting string adjustments to Autohotkey syntax.
    Implementation is simple: printf(fmtstr, params*) => outputdebug(format(fmtstr, params*)).

    Please note that the output of this function is only sent to the IDE debug console. And only if a debugger is connected to the IDE active session.
    No MsgBox is invoked!
LIBHPDF.zip
LIBHPDF.ahk v1.3 + libhpdf.dll v2.0.8
(535.37 KiB) Downloaded 37 times
Please post your script code inside [code] ... [/code] block. Thank you.
just me
Posts: 9542
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: Run AHK V2 as ANSI and 32-bit

10 Nov 2023, 06:17

Hi @vmech,

I think I found the issue.

I've been quite sure that the libhpdf.dll is using __stdcall. So I removed the Cdecl from libhpdf.ahk.

After that i got an error for HPDF_Page_SetSlideShow(): Too many parameters or needs Cdecl. Looking at the function I found

Code: Select all

HPDF_Page_SetSlideShow(hPage, type, disp_time, trans_time) => DllCall("libhpdf\HPDF_Free", "Ptr", hPage, "Int", type, "Float", disp_time, "Float", trans_time, "UInt")
I fixed the function name and it worked.

Code: Select all

HPDF_Page_SetSlideShow(hPage, type, disp_time, trans_time) => DllCall("libhpdf\HPDF_Page_SetSlideShow", "Ptr", hPage, "Int", type, "Float", disp_time, "Float", trans_time, "UInt")
After that a new error was thrown by the error_handler: 0x1023 HPDF_INVALID_DESTINATION. It was caused by the HPDF_Page_CreateLinkAnnot() function call.

Code: Select all

HPDF_Page_CreateLinkAnnot(hPage, rect, dst) => DllCall("libhpdf\HPDF_Page_CreateLinkAnnot", "Ptr", hPage, "Ptr", rect, "Ptr", dst, "Ptr")
This function is dokumented as

Code: Select all

#include "apdf.h"

HPDF_Annotation
HPDF_Page_CreateLinkAnnot  (HPDF_Page          page,
                            HPDF_Rect          rect,
                            HPDF_Destination   dst);
The second parameter rect is expected to be passed by value, not as a pointer. That's also true for all other function expecting a HPDF_Rect structure. So I changed the function to

Code: Select all

HPDF_Page_CreateLinkAnnot(hPage, rect, dst) => DllCall("libhpdf\HPDF_Page_CreateLinkAnnot", "Ptr", hPage,
                                                        "Float", rect.left, "Float", rect.bottom,
                                                        "Float", rect.right, "Float", rect.top,
                                                        "Ptr", dst, "Ptr")
The demo is working now.
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

11 Nov 2023, 02:38

just me wrote:
10 Nov 2023, 06:17
Hi @vmech,

I think I found the issue.
Excellent job my friend! Thank you very much! :bravo:
just me wrote:
10 Nov 2023, 06:17
I've been quite sure that the libhpdf.dll is using __stdcall. So I removed the Cdecl from libhpdf.ahk.

After that i got an error for HPDF_Page_SetSlideShow(): Too many parameters or needs Cdecl. Looking at the function I found

I fixed the function name and it worked.
Yep. This annoying bug come from V1 source. And no anyone had noticed him before... :crazy:
just me wrote:
10 Nov 2023, 06:17
After that a new error was thrown by the error_handler: 0x1023 HPDF_INVALID_DESTINATION. It was caused by the HPDF_Page_CreateLinkAnnot() function call.

This function is dokumented as

The second parameter rect is expected to be passed by value, not as a pointer. That's also true for all other function expecting a HPDF_Rect structure. So I changed the function to

Code: Select all

HPDF_Page_CreateLinkAnnot(hPage, rect, dst) => DllCall("libhpdf\HPDF_Page_CreateLinkAnnot", "Ptr", hPage,
                                                        "Float", rect.left, "Float", rect.bottom,
                                                        "Float", rect.right, "Float", rect.top,
                                                        "Ptr", dst, "Ptr")
The demo is working now.
Very, very strange API. With an equally strange wrapper. A crutch on a crutch. And bugs.
Bugs everywhere.

OK, then the latest bugfix.
Also, starting implementation - now all structure classes can accept an array with values ​​during initialization.
For HPDF_DashMode this input array fills the dash_ptn buffer only.
LIBHPDF.zip
LIBHPDF.ahk v1.4-dev
(8.02 KiB) Downloaded 40 times
Please post your script code inside [code] ... [/code] block. Thank you.
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

15 Nov 2023, 00:38

In my attempts to compile libhpdf.dll to a more recent version, I was still able to compile 2.3.0-RELEASE using CMake 3.27 and MinGW 8.1.
Just without libpng and zlib for now.
HPDF_GetVersion returns the internal version as 2.3.0RC2.
But here's the problem: out of ignorance, I compiled a 64-bit library :lol:
And what’s most interesting: it connects normally and works with 64-bit Autohotkey. And pdf files from demos are also makes normally.
Please post your script code inside [code] ... [/code] block. Thank you.
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

15 Nov 2023, 06:48

Gotcha!
Now I have both libraries, 32-bit and 64-bit. I have not yet tried to compile them with pnglib and zlib. But I'll definitely try.

Warning: This is just an experiment for now. At my and yours risk and danger.
It is no longer necessary to adhere to the strict requirement for Autohotkey bit depth (probably :lol:).
There is no need to change the path to the library - if something goes wrong, then HPDF_LoadDll itself will try to correct the path and load the appropriate library.
The main thing is to adhere to the subfolder structure in the Lib folder as in the archive file.
LIBHPDF.zip
LIBHPDF.ahk v1.4.1-dev + 32-bit/64-bit libhpdf.dll
(987.9 KiB) Downloaded 39 times
Please post your script code inside [code] ... [/code] block. Thank you.
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

18 Nov 2023, 05:30

I managed to compile 32-bit libhpdf.dll version 2.3.0 with libpng and zlib support.
By the end of the weekend I will try to figure out the rest of this «kitchen» and post all the collected libraries.

Several questions at once:
  1. Version 2.3.0 adds about 80 more functions to the export that are missing in version 2.0.8.
    There is no official documentation for these functions. And it is unlikely to ever appear.
    Do I need to add these functions to the wrapper ?
  2. Maybe it's time to organize a separate topic in «Scripts and functions» ?
    Because this whole performance has already moved into some kind of frantic stage of debugging and assembling almost «everything in the world» :lol:
  3. Is it necessary to publish a set of source codes, and may be pre-compiled support import libs, for self-assembling libhpdf libraries (except for MinGW and CMake binaries, of course)?
Please post your script code inside [code] ... [/code] block. Thank you.
Albireo
Posts: 1777
Joined: 16 Oct 2013, 13:53

Re: Run AHK V2 as ANSI and 32-bit

01 Dec 2023, 12:31

I think You did a fantastic job.
Thought I'd see if I can start creating PDF files again with AHK and LIBHARU.
Downloaded the last file LIBHPDF.ahk v1.4.1-dev + 32-bit/64-bit libhpdf.dll by @devech

Created some new empty directories libharu and libharu\lib
In the directorylibharu\lib I saved the latest LIBHPDF.ahk and libhpdf.dll (32-bit)
Then I get back to the earlier test library and copy the examplefiles (which works)
  • arc_demo.ahk
  • character_map.ahk
  • grid_sheet.ahk
  • line_demo.ahk
  • text_demo.ahk
  • text_demo2.ahk
Then I run .: arc_demo.ahk
Immediately I received the message that hpdf_errors.ahk was missing.
Copied the latest file (hpdf_errors.ahk) I have, into the directory (libharu\lib)
Now the program (arc_demo.ahk) works little longer, but now I got next message .:
Error Call nonexistend.png
Error Call nonexistend.png (65.38 KiB) Viewed 627 times
I have no idea what is going wrong this time...
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

01 Dec 2023, 13:33

Albireo wrote:
01 Dec 2023, 12:31
Immediately I received the message that hpdf_errors.ahk was missing.
:!: hpdf_errors.ahk deprecated. Just comment or delete this line.
Albireo wrote:
01 Dec 2023, 12:31
I have no idea what is going wrong this time...
This could be my fault. Try library linked below (unpack to Libharu folder and confirm overwriting if asked):
Libhpdf_dll_32_64_bits.zip
Libhpdf.dll 32 and 64 bits version 2.3.0-release
(979.76 KiB) Downloaded 32 times

Also be careful! I haven't updated all the demo files to the latest state.
A little later I will post updated versions of the converted demo files here.
Please post your script code inside [code] ... [/code] block. Thank you.
Albireo
Posts: 1777
Joined: 16 Oct 2013, 13:53

Re: Run AHK V2 as ANSI and 32-bit

02 Dec 2023, 08:25

Many thanks!
It seems to work very well, (the little I have tested).

If I understand correctly, only the libhpdf.dll (32-bit) works in the lib directory.
Don't know when 64-bit would be an advantage.

- . _ . - . _ . - . _ . - . _ . - . _ . - . _ . - . _ . - . _ . - . _ . - . _ . - . _ . - . _ .

I think this has to do with something else.
When I run testfile character_map.ahk I get almost no content in the result PDF (126 pages). (attaches the AHK-test file)
Is it correct?
CharacterMap.png
CharacterMap.png (38.29 KiB) Viewed 586 times
Attachments
character_map.ahk
(7.11 KiB) Downloaded 32 times
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

02 Dec 2023, 13:43

Albireo wrote:
02 Dec 2023, 08:25
Is it correct?
Nope. Try this:

Code: Select all

/*
 * << Haru Free PDF Library 2.0.0 >> -- character_map.c
 *
 * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
 *
 * Permission to use, copy, modify, distribute and sell this software
 * and its documentation for any purpose is hereby granted without fee,
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation.
 * It is provided "as is" without express or implied warranty.
 *
 * usage character_map <encoding-name> <low-range-from> <low-range-to>
 *              <high-range-from> <high-range-to>
 * ex. character_map 90ms-RKSJ-V 0x80 0x
 *
 */

#Requires Autohotkey v2.0 32-bit
#include "Lib\LIBHPDF.ahk"

hDll := HPDF_LoadDLL(A_ScriptDir "\Lib\libhpdf.dll")
; printf('libhpdf version {:s}`n', HPDF_GetVersion())

main()

HPDF_UnloadDLL(hDll)

/* end of program */

Chr2(num) {
  static ANSI := Buffer(3, 0), byte, btype
  if ( Abs(num) >> 8 )
    byte := 2, btype := 'UShort'
  else
    byte := 1, btype := 'UChar'
  return StrGet(NumPut(btype, num, ANSI) - byte, byte, 0)
}


draw_page(pdf, page, title_font, font, h_byte, l_byte)
{
  PAGE_WIDTH := 420
  CELL_HEIGHT := 20
  CELL_WIDTH := 20

  idiv := Integer(l_byte / 16)  ; /* <<< Float -> Integer */
  l_byte := idiv * 16
  h_count := 16 - idiv
  page_height := 40 + 40 + (h_count + 1) * CELL_HEIGHT

  HPDF_Page_SetHeight(page, page_height)
  HPDF_Page_SetWidth(page, PAGE_WIDTH)

  HPDF_Page_SetFontAndSize(page, title_font, 10)

  ypos := h_count + 1
  loop
  {
    y := ypos * CELL_HEIGHT + 40

    HPDF_Page_MoveTo(page, 40, y)
    HPDF_Page_LineTo(page, 380, y)
    HPDF_Page_Stroke(page)
    if (ypos < h_count)
    {
      ; unsigned char buf[2];

      ; buf[0] = 16 - ypos - 1
      ; if (buf[0] < 10)
      ;   buf[0] += '0'
      ; else
      ;   buf[0] += ('A' - 10)
      buf := 16 - ypos - 1
      if (buf < 10)
        buf += Ord('0')
      else
        buf += Ord('A') - 10
      ; buf[1] = 0

      w := HPDF_Page_TextWidth(page, Chr2(buf))
      HPDF_Page_BeginText(page)
      HPDF_Page_MoveTextPos(page, 40 + (20 - w) / 2, y + 5)
      HPDF_Page_ShowText(page, Chr2(buf))
      HPDF_Page_EndText(page)
    }

    if (ypos = 0)
      break

    ypos--
  }

  ; for (xpos = 0; xpos <= 17; xpos++)
  loop 18
  {
    xpos := A_Index - 1 ; /* <<< actual index */

    y := (h_count + 1) * CELL_HEIGHT + 40
    x := xpos * CELL_WIDTH + 40

    HPDF_Page_MoveTo(page, x, 40)
    HPDF_Page_LineTo(page, x, y)
    HPDF_Page_Stroke(page)

    if (xpos > 0 && xpos <= 16)
    {
      ; unsigned char buf[2];

      ; buf[0] = xpos - 1
      ; if (buf[0] < 10)
      ;   buf[0] += '0'
      ; else
      ;   buf[0] += ('A' - 10)
      buf := xpos - 1
      if (buf < 10)
        buf += Ord('0')
      else
        buf += Ord('A') - 10
      ; buf[1] = 0

      w := HPDF_Page_TextWidth(page, Chr2(buf))
      HPDF_Page_BeginText(page)
      HPDF_Page_MoveTextPos(page, x + (20 - w) / 2, h_count * CELL_HEIGHT + 45)
      HPDF_Page_ShowText(page, Chr2(buf))
      HPDF_Page_EndText(page)
    }
  }

  HPDF_Page_SetFontAndSize(page, font, 15)

  ypos := h_count
  loop
  {
    y := (ypos - 1) * CELL_HEIGHT + 45

    ; for (xpos = 0; xpos < 16; xpos++)
    loop 16
    {
      xpos := A_Index - 1 ; /* <<< actual index */

      x := xpos * CELL_WIDTH + 40 + CELL_WIDTH

      ; unsigned char buf[3];

      buf0 := h_byte
      buf1 := (16 - ypos) * 16 + xpos
      buf := (buf1 << 8) | buf0
      ; buf[2] := 0x00

      _char := Chr2(buf)
      w := HPDF_Page_TextWidth(page, _char)
      if (w > 0)
      {
        HPDF_Page_BeginText(page)
        HPDF_Page_MoveTextPos(page, x + (20 - w) / 2, y)
        HPDF_Page_ShowText(page, _char)
        HPDF_Page_EndText(page)
      }
    }

    if (ypos = 0)
      break

    ypos--
  }
}

main()
{
  ; HPDF_UINT16 flg[256];
  flg := [], flg.Length := 256

  SplitPath(A_ScriptName,,,, &NoExt)
  fname := A_ScriptDir "\" NoExt ".pdf"

  ; if (argc < 3) {
      ; printf ("usage: character_map <encoding-name> <font-name>\n");
      ; return 1;
  ; }
  argv := ["GBK-EUC-H", "MS-Gothic"]

  pdf := HPDF_New(error_handler, NULL)
  if (!pdf)
  {
    MsgBox("ERROR: cannot create PdfDoc object")
    ExitApp(1)
  }

  /* configure pdf-document (showing outline, compression enabled) */
  HPDF_SetPageMode(pdf, HPDF_PAGE_MODE_USE_OUTLINE)
  HPDF_SetCompressionMode(pdf, HPDF_COMP_ALL)
  HPDF_SetPagesConfiguration(pdf, 10)

  HPDF_UseJPEncodings(pdf)
  HPDF_UseJPFonts(pdf)
  HPDF_UseKREncodings(pdf)
  HPDF_UseKRFonts(pdf)
  HPDF_UseCNSEncodings(pdf)
  HPDF_UseCNSFonts(pdf)
  HPDF_UseCNTEncodings(pdf)
  HPDF_UseCNTFonts(pdf)

  encoder := HPDF_GetEncoder(pdf, argv[1])
  if (HPDF_Encoder_GetType(encoder) != HPDF_ENCODER_TYPE_DOUBLE_BYTE)
  {
    MsgBox(Format("ERROR: {:} is not cmap-encoder", argv[1]))
    HPDF_Free(pdf)
    ExitApp(1)
  }

  font := HPDF_GetFont(pdf, argv[2], argv[1])

  min_l := 255
  min_h := 256
  max_l := 0
  max_h := 0

  loop 256
    flg[A_Index] := 0

  ; for (i = 0; i <= 255; i++)
  loop 256
  {
    i := A_Index - 1  ; /* <<< actual index */
    ; for (j = 20; j <= 255; j++)
    loop 236
    {
      j := A_Index + 19 ; /* <<< actual index */
      ; unsigned char buf[3];
      ; HPDF_ByteType btype;
      ; HPDF_UINT16 code = i * 256 + j;
      ; HPDF_UNICODE unicode;
      code := i * 256 + j

      ; buf[0] := i
      ; buf[1] := j
      ; buf[2] := 0
      buf := i * 256 + j
      ; buf := (i << 8) | j

      btype := HPDF_Encoder_GetByteType(encoder, Chr2(buf), 0)  ; /* <<< Chr2(HPDF_UINT16) */
      unicode := HPDF_Encoder_GetUnicode(encoder, code)

      if (btype = HPDF_BYTE_TYPE_LEAD && unicode != 0x25A1)
      {
        if (min_l > j)
          min_l := j

        if (max_l < j)
          max_l := j

        if (min_h > i)
          min_h := i

        if (max_h < i)
          max_h := i

        flg[i + 1] := 1 ; /* <<< actual index */
      }
    }
  }

  OutputDebug(Format("min_h={:02X}00 max_h={:02X}00 min_l={:04X} max_l={:04X}`n", min_h, max_h, min_l, max_l))

  /* create outline root */
  root := HPDF_CreateOutline(pdf, NULL, argv[1], NULL)
  HPDF_Outline_SetOpened(root, HPDF_TRUE)

  ; for (i = 0; i <= 255; i++)
  loop 256
  {
    i := A_Index - 1  ; /* <<< actual index */
    if (flg[A_Index]) ; /* <<< actual index */
    {
      ; char buf[256];
      buf := ""
      page := HPDF_AddPage(pdf)
      title_font := HPDF_GetFont(pdf, "Helvetica", NULL)

      ; _snprintf(buf, 256, "0x%04X-0x%04X", (i * 256 + min_l), (i * 256 + max_l))
      buf := Format("0x{:04X}-0x{:04X}", (i * 256 + min_l), (i * 256 + max_l))
      outline := HPDF_CreateOutline(pdf, root, buf, NULL)
      dst := HPDF_Page_CreateDestination(page)
      HPDF_Outline_SetDestination(outline, dst)

      draw_page(pdf, page, title_font, font, i, min_l)

      ; _snprintf(buf, 256, "%s (%s) 0x%04X-0x%04X", argv[1], argv[2], (i * 256 + min_l), (i * 256 + max_l))
      buf := Format("{:} ({:}) 0x{:04X}-0x{:04X}", argv[1], argv[2], (i * 256 + min_l), (i * 256 + max_l))
      HPDF_Page_SetFontAndSize(page, title_font, 10)
      HPDF_Page_BeginText(page)
      HPDF_Page_MoveTextPos(page, 40, HPDF_Page_GetHeight(page) - 35)
      HPDF_Page_ShowText(page, buf)
      HPDF_Page_EndText(page)
    }
  }

  HPDF_SaveToFile(pdf, fname)
  HPDF_Free(pdf)

  ; return 0
}
character_map.c is a very strange demo. I'm not entirely sure what kind of result it should produce. Because I don't understand anything at all about these Asian multi-byte encodings :oops:
Please post your script code inside [code] ... [/code] block. Thank you.
Albireo
Posts: 1777
Joined: 16 Oct 2013, 13:53

Re: Run AHK V2 as ANSI and 32-bit

05 Dec 2023, 19:45

The home page for LibHaru is http://libharu.org/

But, LibHaru is described quite thoroughly on this page .: Haru Free PDF Library
How LibHaru works is described with a number of examples, e.g. here.: Haru Free PDF Library - Examples

Regarding previous reasoning around the character map
One example is encoding_list.c (in the middle of the page) or character_map.c (at the bottom of the page)
All the examples are available as source code and show the result - very nice.

Now I testing LibHaru for AHK (currently different PDF-fonts) and it's not going so well.
Don't know, right now, if it's ignorance regarding AHK 2.0 or if it's ignorance of LibHaru C# or if features are still missing in LibHaru AHK or ...

I started by trying to handle a text file written in ANSI (but have given up - for now) -
ansi2pdf.ahk


Then I tried handling fonts from the following code ( font_demo.c - code(ruby) ) - but, the AHK 2.0 translation failed.

Code: Select all

#
# << Haru Free PDF Library 2.0.0 >> -- font_example.rb
#
# Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
#
# Permission to use, copy, modify, distribute and sell this software
# and its documentation for any purpose is hereby granted without fee,
# provided that the above copyright notice appear in all copies and
# that both that copyright notice and this permission notice appear
# in supporting documentation.
# It is provided "as is" without express or implied warranty.
#

require "hpdf"

font_list = ["Courier", "Courier-Bold", "Courier-Oblique", "Courier-BoldOblique", "Helvetica", "Helvetica-Bold", "Helvetica-Oblique", "Helvetica-BoldOblique", "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", "Symbol", "ZapfDingbats", nil]

pdf = HPDFDoc.new

page = pdf.add_page
height = page.get_height
width = page.get_width

page.set_line_width(1.0)
page.rectangle(50.0, 50.0, width - 100.0, height - 110.0)
page.stroke

font1 = pdf.get_font("Helvetica", nil)

title = "Font Example"
page.set_font_and_size(font1, 24.0)
tw = page.text_width(title)
page.begin_text
page.text_out((width - tw) / 2, height - 50.0, title)
page.set_font_and_size(font1, 16.0)
page.text_out(60.0, height - 80.0, "<Standerd Type1 fonts samples>")
page.end_text

samp_text = "abcdefgABCDEFG12345!#$\%&+-@?"

page.begin_text
page.move_text_pos(60.0, height - 105.0)

i = 0
while font_list[i]
  font2 = pdf.get_font(font_list[i], nil)

  page.set_font_and_size(font1, 9.0)
  page.show_text(font_list[i])
  page.move_text_pos(0.0, -18.0)

  page.set_font_and_size(font2, 20.0)
  page.show_text(samp_text)
  page.move_text_pos(0.0, -20.0)

  i = i + 1
end

page.end_text
pdf.save_to_file($0 + ".pdf")
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

06 Dec 2023, 02:40

@Albireo
Your ansi2pdf.ahk is a totally broken. It won't work - there are too many errors in the code.
I have the corrected version and it works correctly.
ansi2pdf.ahk

Also font_demo.ahk works fine.
font_demo.ahk
Please post your script code inside [code] ... [/code] block. Thank you.
Albireo
Posts: 1777
Joined: 16 Oct 2013, 13:53

Re: Run AHK V2 as ANSI and 32-bit

06 Dec 2023, 15:10

Thank you! (Very nice)
It seems so easy when the sample files are adapted to AHK 2.0 (the result is great)

Is it possible to convert the examplefile ttfont_demo.c to AHK 2.0?
ttfont_demo.c (ruby)
vmech
Posts: 361
Joined: 25 Aug 2019, 13:03

Re: Run AHK V2 as ANSI and 32-bit

06 Dec 2023, 16:02

@Albireo
ttfont_demo.ahk

Albireo wrote:
06 Dec 2023, 15:10
ttfont_demo.c (ruby)
I don't know Ruby. Please don't post source code on it.
Please post your script code inside [code] ... [/code] block. Thank you.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: MagEpub, TAC109 and 14 guests