com.github.moaxcp.x11client.protocol.xproto.QueryFontReply Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of x11-client Show documentation
Show all versions of x11-client Show documentation
An x11 client implemented in java
package com.github.moaxcp.x11client.protocol.xproto;
import com.github.moaxcp.x11client.protocol.X11Input;
import com.github.moaxcp.x11client.protocol.X11Output;
import com.github.moaxcp.x11client.protocol.XObject;
import com.github.moaxcp.x11client.protocol.XReply;
import java.io.IOException;
import java.lang.Override;
import java.util.ArrayList;
import java.util.List;
import lombok.Builder;
import lombok.NonNull;
import lombok.Value;
@Value
@Builder
public class QueryFontReply implements XReply {
private short sequenceNumber;
@NonNull
private Charinfo minBounds;
@NonNull
private Charinfo maxBounds;
private short minCharOrByte2;
private short maxCharOrByte2;
private short defaultChar;
private short propertiesLen;
private byte drawDirection;
private byte minByte1;
private byte maxByte1;
private boolean allCharsExist;
private short fontAscent;
private short fontDescent;
private int charInfosLen;
@NonNull
private List properties;
@NonNull
private List charInfos;
public static QueryFontReply readQueryFontReply(byte pad, short sequenceNumber, X11Input in)
throws IOException {
int length = in.readCard32();
Charinfo minBounds = Charinfo.readCharinfo(in);
in.readPad(4);
Charinfo maxBounds = Charinfo.readCharinfo(in);
in.readPad(4);
short minCharOrByte2 = in.readCard16();
short maxCharOrByte2 = in.readCard16();
short defaultChar = in.readCard16();
short propertiesLen = in.readCard16();
byte drawDirection = in.readByte();
byte minByte1 = in.readCard8();
byte maxByte1 = in.readCard8();
boolean allCharsExist = in.readBool();
short fontAscent = in.readInt16();
short fontDescent = in.readInt16();
int charInfosLen = in.readCard32();
List properties = new ArrayList<>(Short.toUnsignedInt(propertiesLen));
for(int i = 0; i < Short.toUnsignedInt(propertiesLen); i++) {
properties.add(Fontprop.readFontprop(in));
}
List charInfos = new ArrayList<>((int) (Integer.toUnsignedLong(charInfosLen)));
for(int i = 0; i < Integer.toUnsignedLong(charInfosLen); i++) {
charInfos.add(Charinfo.readCharinfo(in));
}
QueryFontReply.QueryFontReplyBuilder javaBuilder = QueryFontReply.builder();
javaBuilder.sequenceNumber(sequenceNumber);
javaBuilder.minBounds(minBounds);
javaBuilder.maxBounds(maxBounds);
javaBuilder.minCharOrByte2(minCharOrByte2);
javaBuilder.maxCharOrByte2(maxCharOrByte2);
javaBuilder.defaultChar(defaultChar);
javaBuilder.propertiesLen(propertiesLen);
javaBuilder.drawDirection(drawDirection);
javaBuilder.minByte1(minByte1);
javaBuilder.maxByte1(maxByte1);
javaBuilder.allCharsExist(allCharsExist);
javaBuilder.fontAscent(fontAscent);
javaBuilder.fontDescent(fontDescent);
javaBuilder.charInfosLen(charInfosLen);
javaBuilder.properties(properties);
javaBuilder.charInfos(charInfos);
if(javaBuilder.getSize() < 32) {
in.readPad(32 - javaBuilder.getSize());
}
return javaBuilder.build();
}
@Override
public void write(X11Output out) throws IOException {
out.writeCard8(getResponseCode());
out.writePad(1);
out.writeCard16(sequenceNumber);
out.writeCard32(getLength());
minBounds.write(out);
out.writePad(4);
maxBounds.write(out);
out.writePad(4);
out.writeCard16(minCharOrByte2);
out.writeCard16(maxCharOrByte2);
out.writeCard16(defaultChar);
out.writeCard16(propertiesLen);
out.writeByte(drawDirection);
out.writeCard8(minByte1);
out.writeCard8(maxByte1);
out.writeBool(allCharsExist);
out.writeInt16(fontAscent);
out.writeInt16(fontDescent);
out.writeCard32(charInfosLen);
for(Fontprop t : properties) {
t.write(out);
}
for(Charinfo t : charInfos) {
t.write(out);
}
out.writePadAlign(getSize());
}
@Override
public int getSize() {
return 60 + XObject.sizeOf(properties) + XObject.sizeOf(charInfos);
}
public static class QueryFontReplyBuilder {
public QueryFontReply.QueryFontReplyBuilder drawDirection(FontDraw drawDirection) {
this.drawDirection = (byte) drawDirection.getValue();
return this;
}
public QueryFontReply.QueryFontReplyBuilder drawDirection(byte drawDirection) {
this.drawDirection = drawDirection;
return this;
}
public int getSize() {
return 60 + XObject.sizeOf(properties) + XObject.sizeOf(charInfos);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy